<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <th:block th:include="include :: header('任课教师分析与改进列表')" />
</head>
<body class="pear-container">
     <div class="layui-card">
        <div class="layui-card-body">
            <div class="col-sm-12 search-collapse">
                <form id="formId" class="layui-form">

                    <div class="layui-form-item">
                            <label class="layui-form-label">报告基本信息id：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="reportId" placeholder="请输入报告基本信息id" class="layui-input" />
                        </div>
                                <label class="layui-form-label">图片URL  多张;分割：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="imgUrl" placeholder="请输入图片URL  多张;分割" class="layui-input" />
                        </div>
                                <label class="layui-form-label">文字说明：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="explain" placeholder="请输入文字说明" class="layui-input" />
                        </div>
                                <label class="layui-form-label">原因分析JSON：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="causeJson" placeholder="请输入原因分析JSON" class="layui-input" />
                        </div>
                                <label class="layui-form-label">拟采取的改进措施JSON：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="measuresJson" placeholder="请输入拟采取的改进措施JSON" class="layui-input" />
                        </div>
                        <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="analysisImprovement-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                    </div>
                </form>
            </div>
        </div>
     </div>
         <div class="layui-card">
             <div class="layui-card-body">
                 <table id="analysisImprovement-table" lay-filter="analysisImprovement-table"></table>

                 <script type="text/html" id="analysisImprovement-toolbar">
                     <button  sec:authorize="hasPermission('/system/analysisImprovement/add','system:analysisImprovement:add')"  class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
                         <i class="layui-icon layui-icon-add-1"></i>
                         新增
                     </button>
                     <button  sec:authorize="hasPermission('/system/analysisImprovement/remove','system:analysisImprovement:remove')"   class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
                         <i class="layui-icon layui-icon-delete"></i>
                         删除
                     </button>
                 </script>

                 <script type="text/html" id="analysisImprovement-bar">
                     <button  sec:authorize="hasPermission('/system/analysisImprovement/edit','system:analysisImprovement:edit')"   class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
                     </button>
                     <button  sec:authorize="hasPermission('/system/analysisImprovement/remove','system:analysisImprovement:remove')"   class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
                     </button>
                 </script>
             </div>
         </div>
    <th:block th:include="include :: footer" />
         <script>
             layui.use(['table', 'form', 'jquery','dictionary'], function () {
                 let table = layui.table;
                 let form = layui.form;
                 let $ = layui.jquery;

                 let prefix = "/system/analysisImprovement/";

                 let cols = [
                     [
                         {type: 'checkbox'},
                         {
                             field: 'id',
                             title: '拟采取的改进措施JSON'
                         },
                        {
                             field: 'remark',
                             title: '备注'
                        },
                        {
                             field: 'reportId',
                             title: '报告基本信息id'
                        },
                        {
                             field: 'imgUrl',
                             title: '图片URL  多张;分割'
                        },
                        {
                             field: 'explain',
                             title: '文字说明'
                        },
                        {
                             field: 'causeJson',
                             title: '原因分析JSON'
                        },
                        {
                             field: 'measuresJson',
                             title: '拟采取的改进措施JSON'
                        },
                         {title: '操作', toolbar: '#analysisImprovement-bar', align: 'center', width: 130}
                     ]
                 ]

                 table.render({
                     elem: '#analysisImprovement-table',
                     url: prefix + 'data',
                     page: true,
                     cols: cols,
                     skin: 'line',
                     toolbar: '#analysisImprovement-toolbar',
                     defaultToolbar: [{
                         layEvent: 'refresh',
                         icon: 'layui-icon-refresh',
                     }, 'filter', 'print', 'exports']
                 });

                 table.on('tool(analysisImprovement-table)', function (obj) {
                     if (obj.event === 'remove') {
                         window.remove(obj);
                     } else if (obj.event === 'edit') {
                         window.edit(obj);
                     }
                 });

                 table.on('toolbar(analysisImprovement-table)', function (obj) {
                     if (obj.event === 'add') {
                         window.add();
                     } else if (obj.event === 'refresh') {
                         window.refresh();
                     } else if (obj.event === 'batchRemove') {
                         window.batchRemove(obj);
                     }
                 });

                 form.on('submit(analysisImprovement-query)', function (data) {
                     table.reload('analysisImprovement-table', {where: data.field})
                     return false;
                 });

                 window.add = function () {
                     layer.open({
                         type: 2,
                         title: '新增任课教师分析与改进',
                         shade: 0.1,
                         area: ['550px', '500px'],
                         content: prefix + 'add'
                     });
                 }

                 window.edit = function (obj) {
                     layer.open({
                         type: 2,
                         title: '修改任课教师分析与改进',
                         shade: 0.1,
                         area: ['550px', '500px'],
                         content: prefix + 'edit?id=' + obj.data['id']
                     });
                 }

                 window.remove = function (obj) {
                     layer.confirm('确定要删除该任课教师分析与改进', {icon: 3, title: '提示'}, function (index) {
                         layer.close(index);
                         let loading = layer.load();
                         $.ajax({
                             url: prefix + "remove/" + obj.data['id'],
                             dataType: 'json',
                             type: 'delete',
                             success: function (result) {
                                 layer.close(loading);
                                 if (result.success) {
                                     layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                         obj.del();
                                     });
                                 } else {
                                     layer.msg(result.msg, {icon: 2, time: 1000});
                                 }
                             }
                         })
                     });
                 }

                 window.batchRemove = function (obj) {
                     let data = table.checkStatus(obj.config.id).data;
                     if (data.length === 0) {
                         layer.msg("未选中数据", {icon: 3, time: 1000});
                         return false;
                     }
                     let ids = "";
                     for (let i = 0; i < data.length; i++) {
                         ids += data[i].id + ",";
                     }
                     ids = ids.substr(0, ids.length - 1);
                     layer.confirm('确定要删除这些任课教师分析与改进', {icon: 3, title: '提示'}, function (index) {
                         layer.close(index);
                         let loading = layer.load();
                         $.ajax({
                             url: prefix + "batchRemove",
                             dataType: 'json',
                             data: {"ids":ids},
                             type: 'delete',
                             success: function (result) {
                                 layer.close(loading);
                                 if (result.success) {
                                     layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                         table.reload('analysisImprovement-table');
                                     });
                                 } else {
                                     layer.msg(result.msg, {icon: 2, time: 1000});
                                 }
                             }
                         })
                     });
                 }

                 window.refresh = function (param) {
                     table.reload('analysisImprovement-table', {where: param});
                 }
             })
         </script>
</body>
</html>